import * as api from "../plugins/api.js"
import * as types from './mutation-types'
export const session = async function ({ commit }) {
    
    try {

       let  data = await api.session()
        if (data.userType != "Admin") {
            data = false
            return data
        }else {
            commit(types.SET_USERNAME, data)
            return true
        }
    } catch (err) {
         return false
    }
    
    
}

export const login = async function ({ commit }) {
    let data = false
    try {
        data = await api.asynclogin()
        if (data.userType != "Admin") {
            data = false
        }
    } catch (err) {
        data = false
    }
    commit(types.SET_USERNAME, data)
}
